package com.niu.shop.controller.adminapi.delivery;

import com.niu.core.common.domain.Result;
import com.niu.core.common.domain.PageResult;
import com.niu.shop.service.admin.delivery.param.ShopDeliveryElectronicSheetParam;
import com.niu.shop.service.admin.delivery.param.ShopDeliveryElectronicSheetSearchParam;
import com.niu.shop.service.admin.delivery.IShopDeliveryElectronicSheetService;
import com.niu.shop.service.admin.delivery.vo.ShopDeliveryElectronicSheetInfoVo;
import com.niu.shop.service.admin.delivery.vo.ShopDeliveryElectronicSheetListVo;
import com.niu.core.common.domain.PageParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 电子面单控制器
 */

@RestController
@RequestMapping("adminapi/shop/electronic_sheet")
public class ElectronicSheetController {

    @Resource
    IShopDeliveryElectronicSheetService iShopDeliveryElectronicSheetService;

    /**
     * 电子面单列表
     * @param pageParam 分页
     * @param searchParam 搜索条件
     * @return Result<PageResult<ShopDeliveryElectronicSheetListVo>>
     */
    @GetMapping("/list")
    public Result<PageResult<ShopDeliveryElectronicSheetListVo>> list(@Validated PageParam pageParam,
                                                     @Validated ShopDeliveryElectronicSheetSearchParam searchParam) {
        PageResult<ShopDeliveryElectronicSheetListVo> list = iShopDeliveryElectronicSheetService.list(pageParam, searchParam);
        return Result.success(list);
    }

    /**
     * 电子面单详情
     * @param id 主键ID
     * @return Result<ShopDeliveryElectronicSheetInfoVo>
     */
    @GetMapping("/info")
    public Result<ShopDeliveryElectronicSheetInfoVo> info(@Validated @RequestParam("id") Integer id) {
        ShopDeliveryElectronicSheetInfoVo info = iShopDeliveryElectronicSheetService.info(id);
        return Result.success(info);
    }

    /**
     * 电子面单添加
     * @param addParam 添加参数
     * @return AjaxResult<Object>
     */
    @PostMapping("/add")
    public Result<Object> add(@Validated @RequestBody ShopDeliveryElectronicSheetParam addParam) {
        iShopDeliveryElectronicSheetService.add(addParam);
        return Result.success();
    }

    /**
     * 电子面单编辑
     * @param editParam 编辑参数
     * @return Result<Object>
     */
    @PostMapping("/edit")
    public Result<Object> edit(Integer id, @Validated @RequestBody ShopDeliveryElectronicSheetParam editParam) {
        iShopDeliveryElectronicSheetService.edit(id, editParam);
        return Result.success();
    }

    /**
     * 电子面单删除
     * @param id 参数
     * @return Result<Object>
     */
    @PostMapping("/del")
    public Result<Object> del(@Validated @RequestBody Integer id) {
        iShopDeliveryElectronicSheetService.del(id);
        return Result.success();
    }

    /**
     * 电子面单 获取设置
     *
     * @return
     */
    @GetMapping("/config")
    public Result getConfig() {
        return Result.success();
    }
}
